package com.example.safeassistan.risk.adapter;

import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.safeassistan.R;
import com.example.safeassistan.risk.model.RiskPointListSearchModel;

import java.util.List;

public class RiskMyListAdapter extends BaseQuickAdapter<RiskPointListSearchModel.ResultDTO.RecordsDTO,BaseViewHolder> {
    public RiskMyListAdapter(@Nullable List<RiskPointListSearchModel.ResultDTO.RecordsDTO> data) {
        super(R.layout.item_risk_point_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RiskPointListSearchModel.ResultDTO.RecordsDTO item) {
        ImageView ivType=helper.getView(R.id.ivType);
        ImageView ivStatus=helper.getView(R.id.ivStatus);
        LinearLayout llcontainer=helper.getView(R.id.llcontainer);

        switch (item.getRiskLevel()){
            case 1:
                Glide.with(mContext).load(R.mipmap.icon_shan_red_circle).into(ivType);
                break;
            case 2:
                Glide.with(mContext).load(R.mipmap.icon_shan_orange_circle).into(ivType);
                break;
            case 3:
                Glide.with(mContext).load(R.mipmap.icon_shan_yellow_circle).into(ivType);
                break;
            case 4:
                Glide.with(mContext).load(R.mipmap.icon_shan_blue_circle).into(ivType);
                break;
        }
        switch (item.getIsOutOfControl()){
            case 0:
                ivStatus.setImageResource(R.mipmap.icon_shield);
                llcontainer.setBackgroundColor(mContext.getResources().getColor(R.color.white));
                break;
            case 1:
                ivStatus.setImageResource(R.mipmap.icon_fire);
                llcontainer.setBackgroundColor(mContext.getResources().getColor(R.color.risk_bg));
                break;
        }

        helper.setText(R.id.tvRiskTitle,item.getRiskPointName());
        helper.setText(R.id.tvDepartName,"所属部门："+item.getDepartName());
        helper.setText(R.id.tvCheckCount,"检查次数："+item.getCheckCount()+"次");
    }
}